package com.weitu.threeSimultaneities.projectApproval.service.impl;

import com.weitu.accessory.service.AccessoryUtilService;
import com.weitu.threeSimultaneities.projectApproval.entity.ProjectApproval;
import com.weitu.threeSimultaneities.projectApproval.entity.ProjectSpecialty;
import com.weitu.threeSimultaneities.projectApproval.mapper.ProjectApprovalMapper;
import com.weitu.threeSimultaneities.projectApproval.service.ProjectAcceptService;
import com.weitu.threeSimultaneities.projectApproval.service.ProjectApprovalService;
import com.weitu.threeSimultaneities.projectApproval.service.ProjectDesignService;
import com.weitu.threeSimultaneities.projectApproval.service.ProjectFSDService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ProjectApprovalServiceImpl implements ProjectApprovalService {
    @Autowired
    private ProjectApprovalMapper projectApprovalMapper;
    @Autowired
    private ProjectFSDService projectFSDService;
    @Autowired
    private ProjectDesignService projectDesignService;
    @Autowired
    private AccessoryUtilService accessoryUtilService;

    @Autowired
    private ProjectAcceptService projectAcceptService;

    private static final Logger logger = LoggerFactory.getLogger(ProjectApprovalServiceImpl.class);

    @Override
    public ProjectApproval selectById(String id) {
        return this.projectApprovalMapper.selectById(id);
    }
    @Override
    public ProjectApproval  selectByProjectId(String id) {
        return this.projectApprovalMapper.selectByProjectId(id);
    }

    @Override
    public int deleteByPrimaryKey(String id) {
        int fsdDel=this.projectFSDService.deleteByPrimaryKey(id);//删除可研阶段信息
        int designDel=this.projectDesignService.deleteByProjectApprovalId(id);//删除基础设计阶段信息
        this.projectAcceptService.deleteByProjectApprovalId(id);
        boolean boo=this.accessoryUtilService.deleteAccessoryByBusinessId(id);//删除附件信息
        int flag=this.projectApprovalMapper.deleteByPrimaryKey(id);//删除立项数据
        if(flag==1){
            return 1;
        }else{
            return 0;
        }
    }
    @Override
    public int updateByelective(Map paramMap) {
        return this.projectApprovalMapper.updateByelective(paramMap);
    }

    @Override
    public int insertSelective(Map paramMap) {
        return this.projectApprovalMapper.insertSelective(paramMap);
    }

    @Override
    public List<ProjectApproval> selectByParam(Map paramMap) {

        return this.projectApprovalMapper.selectByParam(paramMap);
    }

    @Override
    public int selectByParamCount(Map paramMap) {
        return this.projectApprovalMapper.selectByParamCount(paramMap);
    }
    @Override
    public   int  insertProjectSpecialty(ProjectSpecialty projectSpecialty){
        return this.projectApprovalMapper.insertProjectSpecialty(projectSpecialty);
    }

    @Override
    public int deleteProjectSpecialty(String id) {
        return this.projectApprovalMapper.deleteProjectSpecialty(id);
    }

}